/*     */ package com.lmpop.trade.ti_gift;
/*     */ 
/*     */ import com.lmpop.frame.QueryList;
/*     */ import com.lmpop.frame.SysMap;
/*     */ import com.lmpop.frame.TradeInterf;
/*     */ import com.lmpop.frame.dao.DbmInterf;
/*     */ import com.lmpop.frame.dao.IbatisDbmImpl;
/*     */ import com.lmpop.frame.exp.ApplicationException;
/*     */ import java.util.Hashtable;
/*     */ import java.util.List;
/*     */ import java.util.Map;
/*     */ 
/*     */ public class Ti_giftInfo
/*     */   implements TradeInterf
/*     */ {
/*     */   QueryList queryList;
/*     */ 
/*     */   public Ti_giftInfo()
/*     */   {
/*  17 */     this.queryList = new QueryList();
/*     */   }
/*     */ 
/*     */   public SysMap insert(DbmInterf dbmMgr, SysMap map) {
/*  21 */     Ti_gift ti_gift = new Ti_gift();
/*  22 */     ti_gift.setGift_id(map.getString("gift_id"));
/*  23 */     ti_gift.setCust_id(map.getString("cust_id"));
/*  24 */     ti_gift.setGift_name(map.getString("gift_name"));
/*  25 */     ti_gift.setGift_type(map.getString("gift_type"));
/*  26 */     ti_gift.setGift_desc(map.getString("gift_desc"));
/*  27 */     ti_gift.setGood_id(map.getString("good_id") == null ? "" : map.getString("good_id"));
/*  28 */     ti_gift.setClass_attr(map.getString("class_attr") == null ? "" : map.getString("class_attr"));
/*  29 */     ti_gift.setGift_no(map.getString("gift_no"));
/*  30 */     ti_gift.setStock_num(map.getString("stock_num"));
/*  31 */     ti_gift.setState_code(map.getString("state_code"));
/*  32 */     ti_gift.setIn_date(map.getString("in_date"));
/*  33 */     ti_gift.setUser_id(map.getString("user_id"));
/*     */ 
/*  35 */     String result_code = "0";
/*     */     try {
/*  37 */       insert(dbmMgr, ti_gift);
/*     */     } catch (ApplicationException e) {
/*  39 */       e.printStackTrace();
/*  40 */       result_code = "1";
/*     */     }
/*  42 */     map.setString("result_code", result_code);
/*  43 */     return map;
/*     */   }
/*     */ 
/*     */   public void insert(DbmInterf dbmMgr, Ti_gift ti_gift) throws ApplicationException {
/*  47 */     dbmMgr.update("insertTi_gift", ti_gift);
/*     */   }
/*     */ 
/*     */   public SysMap delete(DbmInterf dbmMgr, SysMap map) {
/*  51 */     String pkid_string = map.getString("pkid");
/*  52 */     String result_code = "0";
/*     */     try {
/*  54 */       if (!pkid_string.equals("")) {
/*  55 */         String[] pkStr = pkid_string.split("\\|");
/*  56 */         for (int i = 0; i < pkStr.length; i++) {
/*  57 */           if (pkStr[i].equals("")) continue; delete(dbmMgr, pkStr[i]);
/*     */         }
/*     */       }
/*     */     } catch (ApplicationException e) {
/*  61 */       e.printStackTrace();
/*  62 */       result_code = "1";
/*     */     }
/*  64 */     map.setString("result_code", result_code);
/*  65 */     return map;
/*     */   }
/*     */ 
/*     */   public void delete(DbmInterf dbmMgr, String pkid) throws ApplicationException {
/*  69 */     dbmMgr.update("deleteTi_gift", pkid);
/*     */   }
/*     */ 
/*     */   public SysMap update(DbmInterf dbmMgr, SysMap map) {
/*  73 */     Ti_gift ti_gift = new Ti_gift();
/*  74 */     ti_gift.setGift_id(map.getString("gift_id"));
/*  75 */     ti_gift.setGift_name(map.getString("gift_name"));
/*  76 */     ti_gift.setGift_type(map.getString("gift_type"));
/*  77 */     ti_gift.setGift_desc(map.getString("gift_desc"));
/*  78 */     ti_gift.setGood_id(map.getString("good_id") == null ? "" : map.getString("good_id"));
/*  79 */     ti_gift.setClass_attr(map.getString("class_attr") == null ? "" : map.getString("class_attr"));
/*  80 */     ti_gift.setGift_no(map.getString("gift_no"));
/*  81 */     ti_gift.setStock_num(map.getString("stock_num"));
/*  82 */     ti_gift.setState_code(map.getString("state_code"));
/*     */ 
/*  84 */     String result_code = "0";
/*     */     try {
/*  86 */       update(dbmMgr, ti_gift);
/*     */     } catch (ApplicationException e) {
/*  88 */       e.printStackTrace();
/*  89 */       result_code = "1";
/*     */     }
/*  91 */     map.setString("result_code", result_code);
/*  92 */     return map;
/*     */   }
/*     */ 
/*     */   public void update(DbmInterf dbmMgr, Ti_gift ti_gift) throws ApplicationException {
/*  96 */     dbmMgr.update("updateTi_gift", ti_gift);
/*     */   }
/*     */ 
/*     */   public List getListByPage(Object obj, int start, int limit) {
/* 100 */     Hashtable ti_gift = (Hashtable)obj;
/* 101 */     if (start == 0)
/* 102 */       start = 0;
/*     */     else {
/* 104 */       start = (start - 1) * limit;
/*     */     }
/* 106 */     ti_gift.put("start", Integer.valueOf(start));
/* 107 */     ti_gift.put("limit", Integer.valueOf(limit));
/* 108 */     return this.queryList.getList("getListByTi_giftPage", ti_gift);
/*     */   }
/*     */ 
/*     */   public int getCountByObj(Object obj) {
/* 112 */     Hashtable ti_gift = (Hashtable)obj;
/* 113 */     List list = this.queryList.getList("getCountByObjTi_gift", ti_gift);
/* 114 */     int count = 0;
/* 115 */     if ((list != null) && (list.size() > 0)) {
/* 116 */       Hashtable newsMap = (Hashtable)list.get(0);
/* 117 */       if ((newsMap.get("count") != null) && (!newsMap.get("count").toString().equals(""))) {
/* 118 */         count = Integer.parseInt(newsMap.get("count").toString());
/*     */       }
/*     */     }
/* 121 */     return count;
/*     */   }
/*     */ 
/*     */   public List getListByPk(String pk) {
/* 125 */     return this.queryList.getList("getTi_giftByPk", pk);
/*     */   }
/*     */ 
/*     */   public List getListBycust(String pk) {
/* 129 */     return this.queryList.getList("getTi_giftBycust", pk);
/*     */   }
/*     */ 
/*     */   public Map getGiftsByClassAttr(String class_attr) {
/* 133 */     String gift_id = ""; String gift_name = ""; String stock_num = "";
/* 134 */     Map giftsmap = new Hashtable();
/* 135 */     List list = null;
/* 136 */     if ((class_attr == null) || ("".equals(class_attr.trim())))
/* 137 */       list = this.queryList.getList("getGifts");
/*     */     else
/* 139 */       list = this.queryList.getList("getGiftsByClassAttr", class_attr);
/* 140 */     if ((list != null) && (list.size() > 0)) {
/* 141 */       for (int i = 0; i < list.size(); i++) {
/* 142 */         Hashtable map = (Hashtable)list.get(i);
/* 143 */         if (map.get("gift_name") != null) {
/* 144 */           gift_name = map.get("gift_name").toString();
/*     */         }
/* 146 */         if (map.get("gift_id") != null) {
/* 147 */           gift_id = map.get("gift_id").toString();
/*     */         }
/* 149 */         if (map.get("stock_num") != null) {
/* 150 */           stock_num = map.get("stock_num").toString();
/*     */         }
/* 152 */         giftsmap.put(gift_id, gift_name + "|" + stock_num);
/*     */       }
/*     */     }
/* 155 */     return giftsmap;
/*     */   }
/*     */ 
/*     */   public Map getGiftnames() {
/* 159 */     String gift_id = ""; String gift_name = "";
/* 160 */     Map giftsmap = new Hashtable();
/* 161 */     List list = null;
/* 162 */     list = this.queryList.getList("getGiftnames");
/* 163 */     if ((list != null) && (list.size() > 0)) {
/* 164 */       for (int i = 0; i < list.size(); i++) {
/* 165 */         Hashtable map = (Hashtable)list.get(i);
/* 166 */         if (map.get("gift_name") != null) {
/* 167 */           gift_name = map.get("gift_name").toString();
/*     */         }
/* 169 */         if (map.get("gift_id") != null) {
/* 170 */           gift_id = map.get("gift_id").toString();
/*     */         }
/* 172 */         giftsmap.put(gift_id, gift_name);
/*     */       }
/*     */     }
/* 175 */     return giftsmap;
/*     */   }
/*     */ 
/*     */   public int getGiftbyIdorName(String gift_name, String good_id, int gift_type)
/*     */   {
/* 180 */     Ti_gift gift = new Ti_gift();
/* 181 */     gift.setGift_name(gift_name);
/* 182 */     gift.setGood_id(good_id);
/* 183 */     List list = this.queryList.getList("getGiftbyName", gift);
/* 184 */     int count = 0;
/* 185 */     Hashtable newsMap = null;
/* 186 */     if ((list != null) && (list.size() > 0)) {
/* 187 */       newsMap = (Hashtable)list.get(0);
/* 188 */       if ((newsMap.get("count") != null) && (!newsMap.get("count").toString().equals(""))) {
/* 189 */         count = Integer.parseInt(newsMap.get("count").toString());
/*     */       }
/*     */     }
/* 192 */     if (gift_type == 2) {
/* 193 */       list = this.queryList.getList("getGiftbyGoodId", gift);
/* 194 */       if ((list != null) && (list.size() > 0)) {
/* 195 */         newsMap = (Hashtable)list.get(0);
/* 196 */         if ((newsMap.get("count") != null) && (!newsMap.get("count").toString().equals(""))) {
/* 197 */           count += Integer.parseInt(newsMap.get("count").toString());
/*     */         }
/*     */       }
/*     */     }
/* 201 */     return count;
/*     */   }
/*     */ 
/*     */   public void updateGiftsStockNum(Map map)
/*     */   {
/* 206 */     DbmInterf dbmMgr = new IbatisDbmImpl();
/* 207 */     dbmMgr.updateSql("updateGiftsStockNum", map);
/*     */   }
/*     */ }

/* Location:           F:\电商\commons-utils.jar
 * Qualified Name:     com.lmpop.trade.ti_gift.Ti_giftInfo
 * JD-Core Version:    0.6.0
 */